from selenium.webdriver.common.by import By
from Case.python_ui.Test_data.organization_data import Organization

class UserLocator:

    #user菜单
    user_tab=(By.XPATH,"//li[contains(@data-menu-id,'USER_CST_LANDINGPAGE')]/span/div")

    #invite_new_user
    invite_new_user=(By.XPATH,"//button[contains(@class,'btn-primary')]")

    #invite_new_user_email
    new_user_email=(By.CSS_SELECTOR,'[id="creForm_emails"]')

    #role_choose
    user_role_choose_list=(By.ID,'creForm_role')

    #default_role
    #default=(By.XPATH,"//div[contains(@class,'select-item-option-content')]")
    default=(By.XPATH,"(//div[contains(@class,'select-item-option-content')])[1]")


    #org
    org_option=(By.ID,"creForm_organization")

    #org_optin
    def org_option_choose(self,title):
        org_option_choose=(By.CSS_SELECTOR,'[title="%s"]'%title)
        return org_option_choose

    #invite_new_user_ok_button
    invite_new_user_ok_button=(By.CSS_SELECTOR,'[class="antd4-modal-footer"]>:nth-child(2)')

    #user_role
    user_default_role=(By.CSS_SELECTOR,'[title="Default Enterprise Role"]')


    #account_email
    account_email=(By.XPATH,'(//th[@class="antd4-table-cell"])[1]')

    #status_filter
    status_filter=(By.XPATH,'//span[text()="Status"]/../span[@role="button"]/span')


    #status_name
    status_names=(By.XPATH,"(//ul[contains(@class,'menu-without-submenu')])[1]//label/../span")

    #dunning status_filter
    dunning_status_filter=(By.XPATH,'//span[text()="Dunning Status"]/../span[@role="button"]/span')

    #dunning_status_list
    dunning_status_names=(By.XPATH,"(//ul[contains(@class,'menu-without-submenu')])[2]//label/../span")

    # user_name
    user_name=(By.XPATH,'(//th[@class="antd4-table-cell"])[4]')

    #phone_number
    phone_number=(By.XPATH,'(//th[@class="antd4-table-cell"])[5]')

    #user_group
    user_group=(By.XPATH,'(//th[@class="antd4-table-cell"])[6]')

    #orgazation
    orgazation=(By.XPATH,'(//th[@class="antd4-table-cell"])[7]')

    #creation_time
    creation_time=(By.XPATH,'(//th[@class="antd4-table-cell"])[8]')

    #action_button
    action_button=(By.XPATH,'//span[@class="anticon anticon-ellipsis table-operation-ellipsis"]')

    #operation
    operation=(By.XPATH,'//span[contains(@class,"antd4-dropdown-menu-title-content")]')

    #account_phone查询框
    account_phone_query_input=(By.ID,'fuzzy')

    #查询按钮
    account_phone_query_button=(By.XPATH,"//button[contains(@class,'antd4-input-search-button')]")

    #获取email的值
    # get_account=(By.XPATH,"//div[contains(@class,'emailName')]")
    get_account = (By.XPATH, "(//*[contains(@class,'emailName')]/span)[1]")

    # 页面总数total
    num_total = (By.XPATH,'//*[contains(@class,"total")]')


    # 筛选项_normal
    filter_normal = (By.XPATH,'//*[@class="antd4-dropdown antd4-dropdown-placement-bottomRight "]//span[text()="Normal"]/..')

    #dunning筛选项_normal
    dunning_filter_normal=()

    # 确认选择项
    filter_ok = (By.XPATH, '//*[@class="antd4-dropdown antd4-dropdown-placement-bottomRight "]//span[text()="OK"]/..')

    #状态
    status=(By.XPATH,"//span[contains(@class,'badge-status-text')]")

    #user删除按钮
    delete_user_button=(By.XPATH,'(//span[contains(@class,"antd4-dropdown-menu-title-content")])[6]')

    #删除确认
    delete_acknowledge=(By.XPATH,'//div[@class="antd4-modal-body"]//span[@class="antd4-checkbox"]')

    #lock_acknowledge锁确认
    lock_acknowledge=(By.CSS_SELECTOR,'[class="antd4-checkbox-input"]')

    #提交删除
    delete_confirm=(By.XPATH,"//div[contains(@class,'modal-footer')]/button[2]")

    #重置密码按钮
    reset_password_button=(By.XPATH,"//button[contains(@class,'table-operation-btnLine-btn')]")

    #change password send
    change_pwd_send=(By.XPATH,"//button[contains(@class,'background-ghost')]")

    #change password_verification code_input
    change_password_verificationcode_input=(By.ID,'creForm_verifyCode')

    #new_pwd
    new_pwd=(By.CSS_SELECTOR,'[autocomplete="new-password"]')

    #confirm_new_pwd
    confirm_new_pwd=(By.CSS_SELECTOR,'[id="creForm_confirmPassword"]')

    #reset_pwd_ok
    reset_pwd_ok=(By.XPATH,"(//button[contains(@class,'antd4-btn-primary')])[3]")

    #edit_org_select
    edit_org_select=(By.XPATH,'//div[contains(@class,"elect-show-search")]')

    #edit_user_group
    edit_user_group=(By.XPATH,"//div[contains(@class,'select-show-search')]")

    #选择usergroup
    def select_user_group(self,usergroup):
        user_group_ele=(By.CSS_SELECTOR,'[title="%s"]'%usergroup)
        return user_group_ele

    #edit_role
    edit_role=(By.XPATH,"(//span[contains(@class,'selection-item')])[2]")

    #选择role
    def select_role(self,role):
        role_ele=(By.CSS_SELECTOR,'[title="%s"]'%role)
        return role_ele

    #user_page_loading
    user_page_loading=(By.XPATH,"//span[contains(@class,'spin-dot-spin')]")

    #翻页
    page_total=(By.CSS_SELECTOR,'[class="antd4-pagination-total-text"]')

    #reload_button
    reload_button=(By.CSS_SELECTOR,'[aria-label="reload"]')

    #query_result_element
    query_result_element=(By.CSS_SELECTOR,'[class="antd4-table-row antd4-table-row-level-0"]')

    #filter_reset_button
    filter_reset_button=(By.XPATH,'//div[@class="antd4-dropdown antd4-dropdown-placement-bottomRight "]//button[1]')

    #dunning_filter_reset_button
    dunning_filter_reset_button=(By.XPATH,'//div[@class="antd4-dropdown antd4-dropdown-placement-bottomRight "]//button[1]/span')